package com.eveinfo.api.journal;

import java.io.IOException;

import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;

import com.eveinfo.api.AbstractApiParser;
import com.eveinfo.api.ApiAuth;
import com.eveinfo.api.ApiException;
import com.eveinfo.api.NoCacheFoundExecption;


public class JournalParser extends AbstractApiParser<JournalResponse, JournalEntryHandler> {
	protected static final String JOURNAL_URL = "/WalletJournal.xml.aspx";

	private static JournalParser instance;
	
	public static JournalParser getInstance(){
		if(instance == null){
			instance = new JournalParser();
		}
		return instance;
	}
	
	private JournalParser() {
		super(JournalResponse.class, 1, JOURNAL_URL);
	}

	public JournalResponse getJournal(ApiAuth auth, boolean corporation)
			throws IOException, SAXException, ParserConfigurationException,
			ApiException, NoCacheFoundExecption {
		JournalEntryHandler handler = new JournalEntryHandler();
		if (corporation)
			return getResponse(auth, Path.CORP, handler);
		return getResponse(auth, Path.CHARACTER, handler);
	}
}